package cn.wolfcode.wolf2w.job;

import cn.wolfcode.wolf2w.redis.service.IStrategyStatisVORedisService;
import cn.wolfcode.wolf2w.redis.vo.StrategyStatisVO;
import cn.wolfcode.wolf2w.service.IStrategyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

//@Component
public class RedisDataPersistenceJob {
    @Autowired
    private IStrategyStatisVORedisService strategyStatisVORedisService;
    @Autowired
    private IStrategyService strategyService;

@Scheduled(cron="0/5 * * * * ?")
    public  void  work(){
//1、从redis获取所有攻略的vo
    List<StrategyStatisVO> vos =strategyStatisVORedisService.queryVoByPattern("*");

//遍历vos，把vo对象的数据添加到momgodb里
    for (StrategyStatisVO vo : vos) {
        strategyService.updateStrategyByVo(vo);
    }
    System.out.println("vo数据持久化完成");
    }
}
